﻿using System;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using yiCommerce.Core;
using yiCommerce.Mapper;
using yiCommerce.Models.Fans;
using yiCommerce.Service.FriendShips;

namespace yiCommerce.Controllers
{
    public class FanController : Controller
    {

        private IFriendShipService _friendShipService;
        private IWorkContext _workContext;

        public FanController(IFriendShipService friendShipService, IWorkContext workContext)
        {
            _friendShipService = friendShipService;
            _workContext = workContext;
        }

        public ActionResult Index()
        {
            return RedirectToAction("List");
        }

        public ActionResult List()
        {
            var fans = _friendShipService.Fans(_workContext.CurrentCustomer.Id);
            var model = new FanListModel()
                {
                    Fans = fans.Select(FansMapper.ToFanList).ToList()
                };

            ViewBag.Model = model;
            return View();
        }

    }
}
